{$CLEO .cs}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "WD Melee"

// By ArtemQa146

if
    0AA2: 31@ = load_dynamic_library "CLEO+.cleo"
then
    if
        0AA4: 30@ = get_dynamic_library_procedure "GetCleoPlusVersion" library 31@
    then
        0AA7: call_function_return 30@ num_params 0 pop 0 29@
        if
            not 29@ >= 0x1020000
        then
            0AD1: show_formatted_text_highpriority "Cleo+ 1.2.0 (or higher) version is required, the Weapon Details mod is disabled" time 15000
            0AA3: free_dynamic_library 31@
            0A93: terminate_this_custom_script
        end
        0AA3: free_dynamic_library 31@
    end
else
    0AD1: show_formatted_text_highpriority "Cleo+ 1.2.0 (or higher) version is required, the Weapon Details mod is disabled" time 15000
    0AA3: free_dynamic_library 31@
    0A93: terminate_this_custom_script
end

if
    0E2D: is_game_first_start
then
    0F00: load_special_model_dff "bat\bat" txd "bat\bat" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "bat"
    0F00: load_special_model_dff "bat\batb1" txd "bat\bat" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "batb1"
    0F00: load_special_model_dff "bat\batb2" txd "bat\bat" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "batb2"
    0F00: load_special_model_dff "bat\batb3" txd "bat\bat" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "batb3"
    0F00: load_special_model_dff "knifecur\knifecur" txd "knifecur\knifecur" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "knifecur"
    0F00: load_special_model_dff "knifecur\knifecurb1" txd "knifecur\knifecur" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "knifecurb1"
    0F00: load_special_model_dff "knifecur\knifecurb2" txd "knifecur\knifecur" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "knifecurb2"
    0F00: load_special_model_dff "knifecur\knifecurb3" txd "knifecur\knifecur" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "knifecurb3"
    0F00: load_special_model_dff "katana\katana" txd "katana\katana" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "katana"
    0F00: load_special_model_dff "katana\katanab1" txd "katana\katana" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "katanab1"
    0F00: load_special_model_dff "katana\katanab2" txd "katana\katana" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "katanab2"
    0F00: load_special_model_dff "katana\katanab3" txd "katana\katana" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "katanab3"
    0F00: load_special_model_dff "shovel\shovel" txd "shovel\shovel" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "shovel"
    0F00: load_special_model_dff "shovel\shovelb1" txd "shovel\shovel" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "shovelb1"
    0F00: load_special_model_dff "shovel\shovelb2" txd "shovel\shovel" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "shovelb2"
    0F00: load_special_model_dff "shovel\shovelb3" txd "shovel\shovel" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "shovelb3"
    0F00: load_special_model_dff "chnsaw\chnsaw_S" txd "chnsaw\chnsaw" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_s"
    0F00: load_special_model_dff "chnsaw\chnsaw_R" txd "chnsaw\chnsaw" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_R"
    0F00: load_special_model_dff "chnsaw\chnsaw_R2" txd "chnsaw\chnsaw" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_R2"
    0F00: load_special_model_dff "chnsaw\chnsaw_R3" txd "chnsaw\chnsaw" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_R3"
    0F00: load_special_model_dff "chnsaw\chnsaw_p" txd "chnsaw\chnsaw" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_p"
    0F00: load_special_model_dff "chnsaw\chnsaw_p2" txd "chnsaw\chnsaw" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_p2"
end

const
    bat_s = 31@
    bat_r = 30@
    bat_r2 = 29@
    bat_r3 = 28@
    knif_s = 27@
    knif_r = 26@
    knif_r2 = 25@
    knif_r3 = 24@
    katana_s = 23@
    katana_r = 22@
    katana_r2 = 21@
    katana_r3 = 20@
    shovel_s = 19@
    shovel_r = 18@
    shovel_r2 = 17@
    shovel_r3 = 16@
    chainsaw_s = 15@
    chainsaw_r = 14@
    chainsaw_r2 = 13@
    chainsaw_r3 = 12@
    chainsaw_p = 11@
    chainsaw_p2 = 10@
    bat_step = 9@
    knife_step = 8@
    katana_step = 7@
    shovel_step = 6@
    chainsaw_step = 5@
end

repeat
wait 0
until player.Defined(0)

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "bat"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale bat_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "batb1"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale bat_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "batb2"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale bat_r2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "batb3"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale bat_r3 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "knifecur"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale knif_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "knifecurb1"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale knif_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "knifecurb2"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale knif_r2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "knifecurb3"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale knif_r3 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "katana"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale katana_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "katanab1"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale katana_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "katanab2"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale katana_r2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "katanab3"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale katana_r3 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "shovel"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale shovel_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "shovelb1"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale shovel_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "shovelb2"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale shovel_r2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "shovelb3"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale shovel_r3 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_s"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale chainsaw_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors


0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_R"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale chainsaw_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_R2"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale chainsaw_r2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_R3"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale chainsaw_r3 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_p"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale chainsaw_p // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "chnsaw_p2"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale chainsaw_p2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors


0E31: set_render_object_visible bat_s 0
0E31: set_render_object_visible bat_r 0
0E31: set_render_object_visible bat_r2 0
0E31: set_render_object_visible bat_r3 0

0E31: set_render_object_visible knif_s 0
0E31: set_render_object_visible knif_r 0
0E31: set_render_object_visible knif_r2 0
0E31: set_render_object_visible knif_r3 0

0E31: set_render_object_visible katana_s 0
0E31: set_render_object_visible katana_r 0
0E31: set_render_object_visible katana_r2 0
0E31: set_render_object_visible katana_r3 0

0E31: set_render_object_visible shovel_s 0
0E31: set_render_object_visible shovel_r 0
0E31: set_render_object_visible shovel_r2 0
0E31: set_render_object_visible shovel_r3 0

0E31: set_render_object_visible chainsaw_s 0
0E31: set_render_object_visible chainsaw_r 0
0E31: set_render_object_visible chainsaw_r2 0
0E31: set_render_object_visible chainsaw_r3 0
0E31: set_render_object_visible chainsaw_p 0
0E31: set_render_object_visible chainsaw_p2 0


while true
wait 0
    if
        player.Defined(0)
    then
        if
            actor.Driving($PLAYER_ACTOR)
        then
            continue
        end

        0AAA: 1@ = get_script_struct_named 'Bat'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 5
            1@ == 0
        then
            0A92: stream_custom_script "Bat.qa" bat_s bat_r bat_r2 bat_r3 bat_step
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Bat'
            until 1@ > 0
            continue
        end
        
        0AAA: 1@ = get_script_struct_named 'Knfcr'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 4
            1@ == 0
        then
            0A92: stream_custom_script "Knifecur.qa" knif_s knif_r knif_r2 knif_r3 knife_step
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Knfcr'
            until 1@ > 0
            continue
        end
        
        0AAA: 1@ = get_script_struct_named 'Katana'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 8
            1@ == 0
        then
            0A92: stream_custom_script "Katana.qa" katana_s katana_r katana_r2 katana_r3 katana_step
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Katana'
            until 1@ > 0
            continue
        end
        
        0AAA: 1@ = get_script_struct_named 'shovel'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 6
            1@ == 0
        then
            0A92: stream_custom_script "shovel.qa" shovel_s shovel_r shovel_r2 shovel_r3 shovel_step
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'shovel'
            until 1@ > 0
            continue
        end
        
        0AAA: 1@ = get_script_struct_named 'Chnsaw'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 9
            1@ == 0
        then
            0A92: stream_custom_script "Chnsaw.qa" chainsaw_s chainsaw_r chainsaw_r2 chainsaw_r3 chainsaw_p chainsaw_p2 chainsaw_step
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Chnsaw'
            until 1@ > 0
            continue
        end
        
        
        
        0AAA: 1@ = get_script_struct_named 'Bat'
        if
            1@ > 0
        then
            0D2F: 2@ = get_script 1@ var 27
            0085: bat_step = 2@ // (int)
        end
        
        0AAA: 1@ = get_script_struct_named 'Knfcr'
        if
            1@ > 0
        then
            0D2F: 2@ = get_script 1@ var 27
            0085: knife_step = 2@ // (int)
        end
        
        0AAA: 1@ = get_script_struct_named 'Katana'
        if
            1@ > 0
        then
            0D2F: 2@ = get_script 1@ var 27
            0085: katana_step = 2@ // (int)
        end
        
        0AAA: 1@ = get_script_struct_named 'shovel'
        if
            1@ > 0
        then
            0D2F: 2@ = get_script 1@ var 27
            0085: shovel_step = 2@ // (int)
        end
        
        0AAA: 1@ = get_script_struct_named 'Chnsaw'
        if
            1@ > 0
        then
            0D2F: 2@ = get_script 1@ var 27
            0085: chainsaw_step = 2@ // (int)
        end


    end
end